﻿using System;
using System.Runtime.Serialization;

namespace ESoft.Exceptions
{
    /// <summary>
    /// 应用异常
    /// </summary>
    public class AppException : Exception
    {
        /// <summary>
        /// 异常编号
        /// </summary>
        public string Code { get; set; } = "B100";

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="info">异常内容</param>
        /// <param name="context">异常上下文</param>
        protected AppException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="code">错误编号</param>
        /// <param name="message">异常信息</param>
        public AppException(string code, string message) : base(message)
        {
            Code = code;
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="message">异常信息</param>
        /// <param name="innerException">内部异常</param>
        public AppException(string message, Exception innerException) : base(message, innerException)
        {
        }
    }
}
